bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 3 | * |
| 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 SHIMIZU | 3559c31 | 2015-11-04 14:59:31 -0800 | [diff] [blame] | 16 | package org.onosproject.pcepio.protocol; |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 17 | |
| 18 | import org.jboss.netty.buffer.ChannelBuffer; |
| 19 | import org.jboss.netty.buffer.ChannelBuffers; |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 20 | import org.junit.Test; |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 21 | import org.onosproject.pcepio.exceptions.PcepOutOfBoundMessageException; |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 22 | import org.onosproject.pcepio.exceptions.PcepParseException; |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 23 | |
| 24 | import static org.hamcrest.MatcherAssert.assertThat; |
| 25 | import static org.hamcrest.Matchers.instanceOf; |
| 26 | import static org.hamcrest.Matchers.is; |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 27 | |
| 28 | public class PcepLabelUpdateMsgTest { |
| 29 | |
| 30 | /** |
| 31 | * This test case checks for |
| 32 | * <pce-label-download> SRP, LSP, LABEL Object. |
| 33 | * in PcepLabelUpdate message. |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 34 | */ |
| 35 | @Test |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 36 | public void labelUpdateMessageTest1() throws PcepParseException, PcepOutOfBoundMessageException { |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 37 | |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 38 | byte[] labelUpdate = new byte[]{0x20, (byte) 0xE2, 0x00, 0x24, // common header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 39 | 0x21, 0x10, 0x00, 0x0C, // SRP Object Header |
| 40 | 0x00, 0x00, 0x00, 0x00, |
| 41 | 0x00, 0x00, 0x00, 0x10, |
| 42 | 0x20, 0x10, 0x00, 0x08, // LSP Object Header |
| 43 | 0x00, 0x01, 0x00, 0x00, |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 44 | (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 45 | 0x00, 0x00, 0x00, 0x00, |
Priyanka B | 21f4b73 | 2016-03-21 20:54:12 +0530 | [diff] [blame] | 46 | 0x00, 0x10, 0x10, 0x00}; |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 47 | |
| 48 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 49 | buffer.writeBytes(labelUpdate); |
| 50 | |
| 51 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 52 | PcepMessage message = null; |
| 53 | |
| 54 | message = reader.readFrom(buffer); |
| 55 | |
| 56 | byte[] testLabelUpdateMsg = {0}; |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 57 | assertThat(message, instanceOf(PcepLabelUpdateMsg.class)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 58 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 59 | |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 60 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 61 | message.writeTo(buf); |
| 62 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 63 | int readLen = buf.writerIndex(); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 64 | testLabelUpdateMsg = new byte[readLen]; |
| 65 | buf.readBytes(testLabelUpdateMsg, 0, readLen); |
| 66 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 67 | assertThat(testLabelUpdateMsg, is(labelUpdate)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | /** |
| 71 | * This test case checks for |
| 72 | * <pce-label-download> SRP, LSP, LABEL Object, LABEL Object. |
| 73 | * in PcepLabelUpdate message. |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 74 | */ |
| 75 | @Test |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 76 | public void labelUpdateMessageTest2() throws PcepParseException, PcepOutOfBoundMessageException { |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 77 | |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 78 | byte[] labelUpdate = new byte[]{0x20, (byte) 0xE2, 0x00, 0x30, // common header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 79 | 0x21, 0x10, 0x00, 0x0C, // SRP Object Header |
| 80 | 0x00, 0x00, 0x00, 0x00, |
| 81 | 0x00, 0x00, 0x00, 0x10, |
| 82 | 0x20, 0x10, 0x00, 0x08, // LSP Object Header |
| 83 | 0x00, 0x01, 0x00, 0x00, |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 84 | (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 85 | 0x00, 0x00, 0x00, 0x00, |
Priyanka B | 21f4b73 | 2016-03-21 20:54:12 +0530 | [diff] [blame] | 86 | 0x00, 0x44, 0x00, 0x00, |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 87 | (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 88 | 0x00, 0x00, 0x00, 0x00, |
Priyanka B | 21f4b73 | 2016-03-21 20:54:12 +0530 | [diff] [blame] | 89 | 0x00, 0x79, 0x00, 0x00}; |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 90 | |
| 91 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 92 | buffer.writeBytes(labelUpdate); |
| 93 | |
| 94 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 95 | PcepMessage message = null; |
| 96 | |
| 97 | message = reader.readFrom(buffer); |
| 98 | |
| 99 | byte[] testLabelUpdateMsg = {0}; |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 100 | assertThat(message, instanceOf(PcepLabelUpdateMsg.class)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 101 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 102 | message.writeTo(buf); |
| 103 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 104 | int readLen = buf.writerIndex(); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 105 | testLabelUpdateMsg = new byte[readLen]; |
| 106 | buf.readBytes(testLabelUpdateMsg, 0, readLen); |
| 107 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 108 | assertThat(testLabelUpdateMsg, is(labelUpdate)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | /** |
| 112 | * This test case checks for |
| 113 | * <pce-label-map> SRP, LABEL, FEC Object. |
| 114 | * in PcepLabelUpdate message. |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 115 | */ |
| 116 | @Test |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 117 | public void labelUpdateMessageTest3() throws PcepParseException, PcepOutOfBoundMessageException { |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 118 | |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 119 | byte[] labelUpdate = new byte[]{0x20, (byte) 0xE2, 0x00, 0x24, // common header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 120 | 0x21, 0x10, 0x00, 0x0C, // SRP Object Header |
| 121 | 0x00, 0x00, 0x00, 0x00, |
| 122 | 0x00, 0x00, 0x00, 0x10, |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 123 | (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 124 | 0x00, 0x00, 0x00, 0x00, |
Priyanka B | 21f4b73 | 2016-03-21 20:54:12 +0530 | [diff] [blame] | 125 | 0x00, 0x79, 0x00, 0x00, |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 126 | (byte) 0xE2, 0x10, 0x00, 0x08, // FEC Object Header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 127 | 0x0A, 0x0A, 0x0B, 0x0B}; |
| 128 | |
| 129 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 130 | buffer.writeBytes(labelUpdate); |
| 131 | |
| 132 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 133 | PcepMessage message = null; |
| 134 | |
| 135 | message = reader.readFrom(buffer); |
| 136 | |
| 137 | byte[] testLabelUpdateMsg = {0}; |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 138 | assertThat(message, instanceOf(PcepLabelUpdateMsg.class)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 139 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 140 | message.writeTo(buf); |
| 141 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 142 | int readLen = buf.writerIndex(); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 143 | testLabelUpdateMsg = new byte[readLen]; |
| 144 | buf.readBytes(testLabelUpdateMsg, 0, readLen); |
| 145 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 146 | assertThat(testLabelUpdateMsg, is(labelUpdate)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | /** |
| 150 | * This test case checks for |
| 151 | * <pce-label-download> SRP, LSP, LABEL, LABEL, <pce-label-download> SRP, LSP, LABEL |
| 152 | * in PcepLabelUpdate message. |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 153 | */ |
| 154 | @Test |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 155 | public void labelUpdateMessageTest4() throws PcepParseException, PcepOutOfBoundMessageException { |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 156 | |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 157 | byte[] labelUpdate = new byte[]{0x20, (byte) 0xE2, 0x00, 0x50, // common header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 158 | 0x21, 0x10, 0x00, 0x0C, // SRP Object Header |
| 159 | 0x00, 0x00, 0x00, 0x00, |
| 160 | 0x00, 0x00, 0x00, 0x10, |
| 161 | 0x20, 0x10, 0x00, 0x08, // LSP Object Header |
| 162 | 0x00, 0x01, 0x00, 0x00, |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 163 | (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 164 | 0x00, 0x00, 0x00, 0x00, |
Priyanka B | 21f4b73 | 2016-03-21 20:54:12 +0530 | [diff] [blame] | 165 | 0x00, 0x66, 0x00, 0x00, |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 166 | (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 167 | 0x00, 0x00, 0x00, 0x00, |
Priyanka B | 21f4b73 | 2016-03-21 20:54:12 +0530 | [diff] [blame] | 168 | 0x00, 0x68, 0x00, 0x00, |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 169 | 0x21, 0x10, 0x00, 0x0C, // SRP Object Header |
| 170 | 0x00, 0x00, 0x00, 0x00, |
| 171 | 0x00, 0x00, 0x00, 0x11, |
| 172 | 0x20, 0x10, 0x00, 0x08, // LSP Object Header |
| 173 | 0x00, 0x02, 0x00, 0x00, |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 174 | (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 175 | 0x00, 0x00, 0x00, 0x00, |
Priyanka B | 21f4b73 | 2016-03-21 20:54:12 +0530 | [diff] [blame] | 176 | 0x00, 0x44, 0x00, 0x00}; |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 177 | |
| 178 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 179 | buffer.writeBytes(labelUpdate); |
| 180 | |
| 181 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 182 | PcepMessage message = null; |
| 183 | |
| 184 | message = reader.readFrom(buffer); |
| 185 | |
| 186 | byte[] testLabelUpdateMsg = {0}; |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 187 | assertThat(message, instanceOf(PcepLabelUpdateMsg.class)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 188 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 189 | message.writeTo(buf); |
| 190 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 191 | int readLen = buf.writerIndex(); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 192 | testLabelUpdateMsg = new byte[readLen]; |
| 193 | buf.readBytes(testLabelUpdateMsg, 0, readLen); |
| 194 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 195 | assertThat(testLabelUpdateMsg, is(labelUpdate)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 196 | } |
| 197 | |
| 198 | /** |
| 199 | * This test case checks for |
| 200 | * <pce-label-map> SRP, LABEL, FEC, <pce-label-map> SRP, LABEL, FEC. |
| 201 | * in PcepLabelUpdate message. |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 202 | */ |
| 203 | @Test |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 204 | public void labelUpdateMessageTest5() throws PcepParseException, PcepOutOfBoundMessageException { |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 205 | |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 206 | byte[] labelUpdate = new byte[]{0x20, (byte) 0xE2, 0x00, 0x44, // common header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 207 | 0x21, 0x10, 0x00, 0x0C, // SRP Object Header |
| 208 | 0x00, 0x00, 0x00, 0x00, |
| 209 | 0x00, 0x00, 0x00, 0x10, |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 210 | (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 211 | 0x00, 0x00, 0x00, 0x01, |
Priyanka B | 21f4b73 | 2016-03-21 20:54:12 +0530 | [diff] [blame] | 212 | 0x00, 0x44, 0x00, 0x00, |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 213 | (byte) 0xE2, 0x10, 0x00, 0x08, // FEC Object Header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 214 | 0x0A, 0x0A, 0x0B, 0x0B, |
| 215 | 0x21, 0x10, 0x00, 0x0C, // SRP Object Header |
| 216 | 0x00, 0x00, 0x00, 0x00, |
| 217 | 0x00, 0x00, 0x00, 0x11, |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 218 | (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 219 | 0x00, 0x00, 0x00, 0x00, |
Priyanka B | 21f4b73 | 2016-03-21 20:54:12 +0530 | [diff] [blame] | 220 | 0x00, 0x44, 0x00, 0x00, |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 221 | (byte) 0xE2, 0x10, 0x00, 0x08, // FEC Object Header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 222 | 0x0A, 0x0A, 0x0C, 0x0C}; |
| 223 | |
| 224 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 225 | buffer.writeBytes(labelUpdate); |
| 226 | |
| 227 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 228 | PcepMessage message = null; |
| 229 | |
| 230 | message = reader.readFrom(buffer); |
| 231 | |
| 232 | byte[] testLabelUpdateMsg = {0}; |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 233 | assertThat(message, instanceOf(PcepLabelUpdateMsg.class)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 234 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 235 | message.writeTo(buf); |
| 236 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 237 | int readLen = buf.writerIndex(); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 238 | testLabelUpdateMsg = new byte[readLen]; |
| 239 | buf.readBytes(testLabelUpdateMsg, 0, readLen); |
| 240 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 241 | assertThat(testLabelUpdateMsg, is(labelUpdate)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | /** |
| 245 | * This test case checks for |
| 246 | * <pce-label-download> SRP, LSP, LABEL, LABEL, <pce-label-download> SRP, LABEL, FEC. |
| 247 | * in PcepLabelUpdate message. |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 248 | */ |
| 249 | @Test |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 250 | public void labelUpdateMessageTest6() throws PcepParseException, PcepOutOfBoundMessageException { |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 251 | |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 252 | byte[] labelUpdate = new byte[]{0x20, (byte) 0xE2, 0x00, 0x50, // common header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 253 | 0x21, 0x10, 0x00, 0x0C, // SRP Object Header |
| 254 | 0x00, 0x00, 0x00, 0x00, |
| 255 | 0x00, 0x00, 0x00, 0x10, |
| 256 | 0x20, 0x10, 0x00, 0x08, // LSP Object Header |
| 257 | 0x00, 0x01, 0x00, 0x00, |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 258 | (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 259 | 0x00, 0x00, 0x00, 0x00, |
Priyanka B | 21f4b73 | 2016-03-21 20:54:12 +0530 | [diff] [blame] | 260 | 0x00, 0x44, 0x00, 0x00, |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 261 | (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 262 | 0x00, 0x00, 0x00, 0x00, |
Priyanka B | 21f4b73 | 2016-03-21 20:54:12 +0530 | [diff] [blame] | 263 | 0x00, 0x44, 0x00, 0x00, |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 264 | 0x21, 0x10, 0x00, 0x0C, // SRP Object Header |
| 265 | 0x00, 0x00, 0x00, 0x00, |
| 266 | 0x00, 0x00, 0x00, 0x12, |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 267 | (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 268 | 0x00, 0x00, 0x00, 0x00, |
Priyanka B | 21f4b73 | 2016-03-21 20:54:12 +0530 | [diff] [blame] | 269 | 0x00, 0x44, 0x00, 0x00, |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 270 | (byte) 0xE2, 0x10, 0x00, 0x08, // FEC Object Header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 271 | 0x0A, 0x0A, 0x0D, 0x0D}; |
| 272 | |
| 273 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 274 | buffer.writeBytes(labelUpdate); |
| 275 | |
| 276 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 277 | PcepMessage message = null; |
| 278 | |
| 279 | message = reader.readFrom(buffer); |
| 280 | |
| 281 | byte[] testLabelUpdateMsg = {0}; |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 282 | assertThat(message, instanceOf(PcepLabelUpdateMsg.class)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 283 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 284 | message.writeTo(buf); |
| 285 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 286 | int readLen = buf.writerIndex(); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 287 | testLabelUpdateMsg = new byte[readLen]; |
| 288 | buf.readBytes(testLabelUpdateMsg, 0, readLen); |
| 289 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 290 | assertThat(testLabelUpdateMsg, is(labelUpdate)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 291 | } |
| 292 | |
| 293 | /** |
| 294 | * This test case checks for |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 295 | * <pce-label-download> SRP, LABEL, FEC, <pce-label-download> SRP, LSP, LABEL, LABEL. |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 296 | * in PcepLabelUpdate message. |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 297 | */ |
| 298 | @Test |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 299 | public void labelUpdateMessageTest7() throws PcepParseException, PcepOutOfBoundMessageException { |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 300 | |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 301 | byte[] labelUpdate = new byte[]{0x20, (byte) 0xE2, 0x00, 0x50, // common header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 302 | 0x21, 0x10, 0x00, 0x0C, // SRP Object Header |
| 303 | 0x00, 0x00, 0x00, 0x00, |
| 304 | 0x00, 0x00, 0x00, 0x12, |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 305 | (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 306 | 0x00, 0x00, 0x00, 0x00, |
Priyanka B | 21f4b73 | 2016-03-21 20:54:12 +0530 | [diff] [blame] | 307 | 0x00, 0x44, 0x00, 0x00, |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 308 | (byte) 0xE2, 0x10, 0x00, 0x08, // FEC Object Header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 309 | 0x0A, 0x0A, 0x0D, 0x0D, |
| 310 | 0x21, 0x10, 0x00, 0x0C, // SRP Object Header |
| 311 | 0x00, 0x00, 0x00, 0x00, |
| 312 | 0x00, 0x00, 0x00, 0x10, |
| 313 | 0x20, 0x10, 0x00, 0x08, // LSP Object Header |
| 314 | 0x00, 0x01, 0x00, 0x00, |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 315 | (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 316 | 0x00, 0x00, 0x00, 0x00, |
Priyanka B | 21f4b73 | 2016-03-21 20:54:12 +0530 | [diff] [blame] | 317 | 0x00, 0x44, 0x00, 0x00, |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 318 | (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 319 | 0x00, 0x00, 0x00, 0x00, |
Priyanka B | 21f4b73 | 2016-03-21 20:54:12 +0530 | [diff] [blame] | 320 | 0x00, 0x44, 0x00, 0x00}; |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 321 | |
| 322 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 323 | buffer.writeBytes(labelUpdate); |
| 324 | |
| 325 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 326 | PcepMessage message = null; |
| 327 | |
| 328 | message = reader.readFrom(buffer); |
| 329 | |
| 330 | byte[] testLabelUpdateMsg = {0}; |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 331 | assertThat(message, instanceOf(PcepLabelUpdateMsg.class)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 332 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 333 | message.writeTo(buf); |
| 334 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 335 | int readLen = buf.writerIndex(); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 336 | testLabelUpdateMsg = new byte[readLen]; |
| 337 | buf.readBytes(testLabelUpdateMsg, 0, readLen); |
| 338 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 339 | assertThat(testLabelUpdateMsg, is(labelUpdate)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | /** |
| 343 | * This test case checks for |
| 344 | * <pce-label-download> SRP, LABEL, FEC, <pce-label-download> SRP, LSP, LABEL, LABEL. |
| 345 | * <pce-label-download> SRP, LSP, LABEL, LABEL. |
| 346 | * in PcepLabelUpdate message. |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 347 | */ |
| 348 | @Test |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 349 | public void labelUpdateMessageTest8() throws PcepParseException, PcepOutOfBoundMessageException { |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 350 | |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 351 | byte[] labelUpdate = new byte[]{0x20, (byte) 0xE2, 0x00, 0x7C, // common header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 352 | 0x21, 0x10, 0x00, 0x0C, // SRP Object Header |
| 353 | 0x00, 0x00, 0x00, 0x00, |
| 354 | 0x00, 0x00, 0x00, 0x12, |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 355 | (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 356 | 0x00, 0x00, 0x00, 0x00, |
Priyanka B | 21f4b73 | 2016-03-21 20:54:12 +0530 | [diff] [blame] | 357 | 0x00, 0x44, 0x00, 0x00, |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 358 | (byte) 0xE2, 0x10, 0x00, 0x08, // FEC Object Header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 359 | 0x0A, 0x0A, 0x0D, 0x0D, |
| 360 | 0x21, 0x10, 0x00, 0x0C, // SRP Object Header |
| 361 | 0x00, 0x00, 0x00, 0x00, |
| 362 | 0x00, 0x00, 0x00, 0x10, |
| 363 | 0x20, 0x10, 0x00, 0x08, // LSP Object Header |
| 364 | 0x00, 0x01, 0x00, 0x00, |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 365 | (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 366 | 0x00, 0x00, 0x00, 0x00, |
Priyanka B | 21f4b73 | 2016-03-21 20:54:12 +0530 | [diff] [blame] | 367 | 0x00, 0x44, 0x00, 0x00, |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 368 | (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 369 | 0x00, 0x00, 0x00, 0x00, |
Priyanka B | 21f4b73 | 2016-03-21 20:54:12 +0530 | [diff] [blame] | 370 | 0x00, 0x44, 0x00, 0x00, |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 371 | 0x21, 0x10, 0x00, 0x0C, // SRP Object Header |
| 372 | 0x00, 0x00, 0x00, 0x00, |
| 373 | 0x00, 0x00, 0x00, 0x10, |
| 374 | 0x20, 0x10, 0x00, 0x08, // LSP Object Header |
| 375 | 0x00, 0x01, 0x00, 0x00, |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 376 | (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 377 | 0x00, 0x00, 0x00, 0x00, |
Priyanka B | 21f4b73 | 2016-03-21 20:54:12 +0530 | [diff] [blame] | 378 | 0x00, 0x44, 0x00, 0x00, |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 379 | (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 380 | 0x00, 0x00, 0x00, 0x00, |
Priyanka B | 21f4b73 | 2016-03-21 20:54:12 +0530 | [diff] [blame] | 381 | 0x00, 0x44, 0x00, 0x00}; |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 382 | |
| 383 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 384 | buffer.writeBytes(labelUpdate); |
| 385 | |
| 386 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 387 | PcepMessage message = null; |
| 388 | |
| 389 | message = reader.readFrom(buffer); |
| 390 | |
| 391 | byte[] testLabelUpdateMsg = {0}; |
| 392 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 393 | assertThat(message, instanceOf(PcepLabelUpdateMsg.class)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 394 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 395 | message.writeTo(buf); |
| 396 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 397 | int readLen = buf.writerIndex(); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 398 | testLabelUpdateMsg = new byte[readLen]; |
| 399 | buf.readBytes(testLabelUpdateMsg, 0, readLen); |
| 400 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 401 | assertThat(testLabelUpdateMsg, is(labelUpdate)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 402 | } |
| 403 | } |