blob: 9692119969073e9f79c53cda8a034dba79330a71 [file] [log] [blame]
bharat saraswale2e7a002015-08-21 22:47:30 +05301/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
bharat saraswale2e7a002015-08-21 22:47:30 +05303 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Sho SHIMIZU3559c312015-11-04 14:59:31 -080016package org.onosproject.pcepio.protocol;
bharat saraswale2e7a002015-08-21 22:47:30 +053017
18import org.jboss.netty.buffer.ChannelBuffer;
19import org.jboss.netty.buffer.ChannelBuffers;
bharat saraswale2e7a002015-08-21 22:47:30 +053020import org.junit.Test;
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +053021import org.onosproject.pcepio.exceptions.PcepOutOfBoundMessageException;
bharat saraswale2e7a002015-08-21 22:47:30 +053022import org.onosproject.pcepio.exceptions.PcepParseException;
Sho SHIMIZU3559c312015-11-04 14:59:31 -080023
24import static org.hamcrest.MatcherAssert.assertThat;
25import static org.hamcrest.Matchers.instanceOf;
26import static org.hamcrest.core.Is.is;
bharat saraswale2e7a002015-08-21 22:47:30 +053027
bharat saraswalb4e5cbe2015-09-02 19:33:20 +053028public class PcepReportMsgExtTest {
bharat saraswale2e7a002015-08-21 22:47:30 +053029
30 /**
31 * This test case checks forSRP Object,LSP Object(symbolic path tlv),ERO Object
32 * SRP Object,LSP Object(symbolic path tlv,ERO Object,LSPA Object,BandWidth Object,Metric-list,RRO Object
33 * in PcRpt message.
bharat saraswale2e7a002015-08-21 22:47:30 +053034 */
35 @Test
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +053036 public void reportMessageTest39() throws PcepParseException, PcepOutOfBoundMessageException {
bharat saraswale2e7a002015-08-21 22:47:30 +053037
38 byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x98,
39 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
bharat saraswalb4e5cbe2015-09-02 19:33:20 +053040 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
bharat saraswale2e7a002015-08-21 22:47:30 +053041 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
42 0x07, 0x10, 0x00, 0x14, //ERO Object
bharat saraswalb4e5cbe2015-09-02 19:33:20 +053043 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
44 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
bharat saraswale2e7a002015-08-21 22:47:30 +053045 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
bharat saraswalb4e5cbe2015-09-02 19:33:20 +053046 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
bharat saraswale2e7a002015-08-21 22:47:30 +053047 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
48 0x07, 0x10, 0x00, 0x14, //ERO object
bharat saraswalb4e5cbe2015-09-02 19:33:20 +053049 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
50 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
bharat saraswale2e7a002015-08-21 22:47:30 +053051 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO object
52 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
53 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
54 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
55 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
56 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
57
58 byte[] testReportMsg = {0};
59 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
60 buffer.writeBytes(reportMsg);
61
62 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
63 PcepMessage message = null;
64
65 message = reader.readFrom(buffer);
Priyanka bhaskar3e1a6972015-08-27 15:31:54 +053066 assertThat(message, instanceOf(PcepReportMsg.class));
bharat saraswale2e7a002015-08-21 22:47:30 +053067 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
68 message.writeTo(buf);
69
Priyanka bhaskar3e1a6972015-08-27 15:31:54 +053070 int readLen = buf.writerIndex();
bharat saraswale2e7a002015-08-21 22:47:30 +053071 testReportMsg = new byte[readLen];
72 buf.readBytes(testReportMsg, 0, readLen);
73
Priyanka bhaskar3e1a6972015-08-27 15:31:54 +053074 assertThat(testReportMsg, is(reportMsg));
bharat saraswale2e7a002015-08-21 22:47:30 +053075 }
76
77 /**
78 * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object
79 * SRP Object,LSP Object(symbolic path tlv),ERO Object
80 * in PcRpt message.
bharat saraswale2e7a002015-08-21 22:47:30 +053081 */
82 @Test
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +053083 public void reportMessageTest40() throws PcepParseException, PcepOutOfBoundMessageException {
bharat saraswale2e7a002015-08-21 22:47:30 +053084
85 byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x64,
86 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
bharat saraswalb4e5cbe2015-09-02 19:33:20 +053087 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
bharat saraswale2e7a002015-08-21 22:47:30 +053088 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
89 0x07, 0x10, 0x00, 0x14, //ERO object
bharat saraswalb4e5cbe2015-09-02 19:33:20 +053090 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
91 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
bharat saraswale2e7a002015-08-21 22:47:30 +053092 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
bharat saraswalb4e5cbe2015-09-02 19:33:20 +053093 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
bharat saraswale2e7a002015-08-21 22:47:30 +053094 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
95 0x07, 0x10, 0x00, 0x14, //ERO object
bharat saraswalb4e5cbe2015-09-02 19:33:20 +053096 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
97 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00};
bharat saraswale2e7a002015-08-21 22:47:30 +053098
99 byte[] testReportMsg = {0};
100 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
101 buffer.writeBytes(reportMsg);
102
103 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
104 PcepMessage message = null;
105
106 message = reader.readFrom(buffer);
Priyanka bhaskar3e1a6972015-08-27 15:31:54 +0530107 assertThat(message, instanceOf(PcepReportMsg.class));
bharat saraswale2e7a002015-08-21 22:47:30 +0530108 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
109 message.writeTo(buf);
110
Priyanka bhaskar3e1a6972015-08-27 15:31:54 +0530111 int readLen = buf.writerIndex();
bharat saraswale2e7a002015-08-21 22:47:30 +0530112 testReportMsg = new byte[readLen];
113 buf.readBytes(testReportMsg, 0, readLen);
114
Priyanka bhaskar3e1a6972015-08-27 15:31:54 +0530115 assertThat(testReportMsg, is(reportMsg));
bharat saraswale2e7a002015-08-21 22:47:30 +0530116 }
117
118 /**
119 * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object
120 * SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object
121 * in PcRpt message.
bharat saraswale2e7a002015-08-21 22:47:30 +0530122 */
123 @Test
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530124 public void reportMessageTest41() throws PcepParseException, PcepOutOfBoundMessageException {
bharat saraswale2e7a002015-08-21 22:47:30 +0530125
126 byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x8c,
127 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
bharat saraswalb4e5cbe2015-09-02 19:33:20 +0530128 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
bharat saraswale2e7a002015-08-21 22:47:30 +0530129 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
130 0x07, 0x10, 0x00, 0x14, //ERO object
bharat saraswalb4e5cbe2015-09-02 19:33:20 +0530131 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
132 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
bharat saraswale2e7a002015-08-21 22:47:30 +0530133 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
134 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
135 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
bharat saraswalb4e5cbe2015-09-02 19:33:20 +0530136 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
bharat saraswale2e7a002015-08-21 22:47:30 +0530137 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
138 0x07, 0x10, 0x00, 0x14, //ERO object
bharat saraswalb4e5cbe2015-09-02 19:33:20 +0530139 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
140 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
bharat saraswale2e7a002015-08-21 22:47:30 +0530141 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, //LSPA object
142 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
143
144 byte[] testReportMsg = {0};
145 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
146 buffer.writeBytes(reportMsg);
147
148 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
149 PcepMessage message = null;
150
151 message = reader.readFrom(buffer);
Priyanka bhaskar3e1a6972015-08-27 15:31:54 +0530152 assertThat(message, instanceOf(PcepReportMsg.class));
bharat saraswale2e7a002015-08-21 22:47:30 +0530153 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
154 message.writeTo(buf);
155
Priyanka bhaskar3e1a6972015-08-27 15:31:54 +0530156 int readLen = buf.writerIndex();
bharat saraswale2e7a002015-08-21 22:47:30 +0530157 testReportMsg = new byte[readLen];
158 buf.readBytes(testReportMsg, 0, readLen);
159
Priyanka bhaskar3e1a6972015-08-27 15:31:54 +0530160 assertThat(testReportMsg, is(reportMsg));
bharat saraswale2e7a002015-08-21 22:47:30 +0530161 }
162
163 /**
164 * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object,BandWidth Object,
165 * Metric-list SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object,BandWidth Object,Metric-list,
166 * RRO Object
167 * in PcRpt message.
bharat saraswale2e7a002015-08-21 22:47:30 +0530168 */
169 @Test
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530170 public void reportMessageTest42() throws PcepParseException, PcepOutOfBoundMessageException {
bharat saraswale2e7a002015-08-21 22:47:30 +0530171
172 byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0xE8,
173 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
bharat saraswalb4e5cbe2015-09-02 19:33:20 +0530174 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
bharat saraswale2e7a002015-08-21 22:47:30 +0530175 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
176 0x07, 0x10, 0x00, 0x14, //ERO object
bharat saraswalb4e5cbe2015-09-02 19:33:20 +0530177 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
178 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
bharat saraswale2e7a002015-08-21 22:47:30 +0530179 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
180 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
181 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
182 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object
183 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
bharat saraswalb4e5cbe2015-09-02 19:33:20 +0530184 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
bharat saraswale2e7a002015-08-21 22:47:30 +0530185 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
186 0x07, 0x10, 0x00, 0x14, //ERO object
Avantika-Huawei56c11842016-04-28 00:56:56 +0530187 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, //ERO IPv4 subobjects
bharat saraswalb4e5cbe2015-09-02 19:33:20 +0530188 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
bharat saraswale2e7a002015-08-21 22:47:30 +0530189 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
190 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
191 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
192 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object
193 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO object
Avantika-Huawei56c11842016-04-28 00:56:56 +0530194 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, //RRO IPv4 subobjects
bharat saraswale2e7a002015-08-21 22:47:30 +0530195 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
196 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
197 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
198 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
199
200 byte[] testReportMsg = {0};
201 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
202 buffer.writeBytes(reportMsg);
203
204 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
205 PcepMessage message = null;
206
207 message = reader.readFrom(buffer);
208
Priyanka bhaskar3e1a6972015-08-27 15:31:54 +0530209 assertThat(message, instanceOf(PcepReportMsg.class));
bharat saraswale2e7a002015-08-21 22:47:30 +0530210 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
211 message.writeTo(buf);
212
Priyanka bhaskar3e1a6972015-08-27 15:31:54 +0530213 int readLen = buf.writerIndex();
bharat saraswale2e7a002015-08-21 22:47:30 +0530214 testReportMsg = new byte[readLen];
215 buf.readBytes(testReportMsg, 0, readLen);
216
Priyanka bhaskar3e1a6972015-08-27 15:31:54 +0530217 assertThat(testReportMsg, is(reportMsg));
bharat saraswale2e7a002015-08-21 22:47:30 +0530218 }
Avantika-Huawei56c11842016-04-28 00:56:56 +0530219
220 /**
221 * Tests PCRpt msg with Path-Setup-Type TLV as SR.
222 *
223 * @throws PcepParseException
224 * @throws PcepOutOfBoundMessageException
225 */
226 @Test
227 public void reportMessageTest43() throws PcepParseException, PcepOutOfBoundMessageException {
228
229 byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x3C,
230 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
231 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV
232 0x00, 0x00, 0x00, 0x01,
233 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
234 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
235 0x07, 0x10, 0x00, 0x14, //ERO object
236 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, //ERO IPv4 subobjects
237 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
238 };
239
240 byte[] testReportMsg = {0};
241 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
242 buffer.writeBytes(reportMsg);
243
244 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
245 PcepMessage message = null;
246
247 message = reader.readFrom(buffer);
248 assertThat(message, instanceOf(PcepReportMsg.class));
249 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
250 message.writeTo(buf);
251
252 int readLen = buf.writerIndex();
253 testReportMsg = new byte[readLen];
254 buf.readBytes(testReportMsg, 0, readLen);
255
256 assertThat(testReportMsg, is(reportMsg));
257 }
258
259 /**
260 * Tests PCRpt msg with Path-Setup-Type TLV as "without SR and without signalling".
261 *
262 * @throws PcepParseException
263 * @throws PcepOutOfBoundMessageException
264 */
265 @Test
266 public void reportMessageTest44() throws PcepParseException, PcepOutOfBoundMessageException {
267
268 byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x3C,
269 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
270 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV
271 0x00, 0x00, 0x00, 0x02,
272 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
273 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
274 0x07, 0x10, 0x00, 0x14, //ERO object
275 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, //ERO IPv4 subobjects
276 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
277 };
278
279 byte[] testReportMsg = {0};
280 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
281 buffer.writeBytes(reportMsg);
282
283 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
284 PcepMessage message = null;
285
286 message = reader.readFrom(buffer);
287 assertThat(message, instanceOf(PcepReportMsg.class));
288 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
289 message.writeTo(buf);
290
291 int readLen = buf.writerIndex();
292 testReportMsg = new byte[readLen];
293 buf.readBytes(testReportMsg, 0, readLen);
294
295 assertThat(testReportMsg, is(reportMsg));
296 }
297
bharat saraswale2e7a002015-08-21 22:47:30 +0530298}