bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014-2015 Open Networking Laboratory |
| 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 | */ |
| 16 | package org.onosproject.pcepio; |
| 17 | |
Priyanka bhaskar | 3e1a697 | 2015-08-27 15:31:54 +0530 | [diff] [blame] | 18 | import static org.hamcrest.MatcherAssert.assertThat; |
| 19 | import static org.hamcrest.Matchers.instanceOf; |
| 20 | import static org.hamcrest.core.Is.is; |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 21 | import org.jboss.netty.buffer.ChannelBuffer; |
| 22 | import org.jboss.netty.buffer.ChannelBuffers; |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 23 | import org.junit.Test; |
| 24 | import org.onosproject.pcepio.exceptions.PcepParseException; |
| 25 | import org.onosproject.pcepio.protocol.PcepFactories; |
| 26 | import org.onosproject.pcepio.protocol.PcepMessage; |
| 27 | import org.onosproject.pcepio.protocol.PcepMessageReader; |
| 28 | import org.onosproject.pcepio.protocol.PcepReportMsg; |
| 29 | |
bharat saraswal | b4e5cbe | 2015-09-02 19:33:20 +0530 | [diff] [blame] | 30 | public class PcepReportMsgExtTest { |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 31 | |
| 32 | /** |
| 33 | * This test case checks forSRP Object,LSP Object(symbolic path tlv),ERO Object |
| 34 | * SRP Object,LSP Object(symbolic path tlv,ERO Object,LSPA Object,BandWidth Object,Metric-list,RRO Object |
| 35 | * in PcRpt message. |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 36 | */ |
| 37 | @Test |
| 38 | public void reportMessageTest39() throws PcepParseException { |
| 39 | |
| 40 | byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x98, |
| 41 | 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object |
bharat saraswal | b4e5cbe | 2015-09-02 19:33:20 +0530 | [diff] [blame] | 42 | 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 43 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv |
| 44 | 0x07, 0x10, 0x00, 0x14, //ERO Object |
bharat saraswal | b4e5cbe | 2015-09-02 19:33:20 +0530 | [diff] [blame] | 45 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, |
| 46 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 47 | 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object |
bharat saraswal | b4e5cbe | 2015-09-02 19:33:20 +0530 | [diff] [blame] | 48 | 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 49 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv |
| 50 | 0x07, 0x10, 0x00, 0x14, //ERO object |
bharat saraswal | b4e5cbe | 2015-09-02 19:33:20 +0530 | [diff] [blame] | 51 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, |
| 52 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 53 | 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO object |
| 54 | 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, |
| 55 | 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, |
| 56 | 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, |
| 57 | 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, |
| 58 | 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; |
| 59 | |
| 60 | byte[] testReportMsg = {0}; |
| 61 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 62 | buffer.writeBytes(reportMsg); |
| 63 | |
| 64 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 65 | PcepMessage message = null; |
| 66 | |
| 67 | message = reader.readFrom(buffer); |
Priyanka bhaskar | 3e1a697 | 2015-08-27 15:31:54 +0530 | [diff] [blame] | 68 | assertThat(message, instanceOf(PcepReportMsg.class)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 69 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 70 | message.writeTo(buf); |
| 71 | |
Priyanka bhaskar | 3e1a697 | 2015-08-27 15:31:54 +0530 | [diff] [blame] | 72 | int readLen = buf.writerIndex(); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 73 | testReportMsg = new byte[readLen]; |
| 74 | buf.readBytes(testReportMsg, 0, readLen); |
| 75 | |
Priyanka bhaskar | 3e1a697 | 2015-08-27 15:31:54 +0530 | [diff] [blame] | 76 | assertThat(testReportMsg, is(reportMsg)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | /** |
| 80 | * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object |
| 81 | * SRP Object,LSP Object(symbolic path tlv),ERO Object |
| 82 | * in PcRpt message. |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 83 | */ |
| 84 | @Test |
| 85 | public void reportMessageTest40() throws PcepParseException { |
| 86 | |
| 87 | byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x64, |
| 88 | 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object |
bharat saraswal | b4e5cbe | 2015-09-02 19:33:20 +0530 | [diff] [blame] | 89 | 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 90 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv |
| 91 | 0x07, 0x10, 0x00, 0x14, //ERO object |
bharat saraswal | b4e5cbe | 2015-09-02 19:33:20 +0530 | [diff] [blame] | 92 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, |
| 93 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 94 | 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object |
bharat saraswal | b4e5cbe | 2015-09-02 19:33:20 +0530 | [diff] [blame] | 95 | 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 96 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv |
| 97 | 0x07, 0x10, 0x00, 0x14, //ERO object |
bharat saraswal | b4e5cbe | 2015-09-02 19:33:20 +0530 | [diff] [blame] | 98 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, |
| 99 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00}; |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 100 | |
| 101 | byte[] testReportMsg = {0}; |
| 102 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 103 | buffer.writeBytes(reportMsg); |
| 104 | |
| 105 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 106 | PcepMessage message = null; |
| 107 | |
| 108 | message = reader.readFrom(buffer); |
Priyanka bhaskar | 3e1a697 | 2015-08-27 15:31:54 +0530 | [diff] [blame] | 109 | assertThat(message, instanceOf(PcepReportMsg.class)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 110 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 111 | message.writeTo(buf); |
| 112 | |
Priyanka bhaskar | 3e1a697 | 2015-08-27 15:31:54 +0530 | [diff] [blame] | 113 | int readLen = buf.writerIndex(); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 114 | testReportMsg = new byte[readLen]; |
| 115 | buf.readBytes(testReportMsg, 0, readLen); |
| 116 | |
Priyanka bhaskar | 3e1a697 | 2015-08-27 15:31:54 +0530 | [diff] [blame] | 117 | assertThat(testReportMsg, is(reportMsg)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | /** |
| 121 | * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object |
| 122 | * SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object |
| 123 | * in PcRpt message. |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 124 | */ |
| 125 | @Test |
| 126 | public void reportMessageTest41() throws PcepParseException { |
| 127 | |
| 128 | byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x8c, |
| 129 | 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object |
bharat saraswal | b4e5cbe | 2015-09-02 19:33:20 +0530 | [diff] [blame] | 130 | 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 131 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv |
| 132 | 0x07, 0x10, 0x00, 0x14, //ERO object |
bharat saraswal | b4e5cbe | 2015-09-02 19:33:20 +0530 | [diff] [blame] | 133 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, |
| 134 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 135 | 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object |
| 136 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 137 | 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object |
bharat saraswal | b4e5cbe | 2015-09-02 19:33:20 +0530 | [diff] [blame] | 138 | 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 139 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv |
| 140 | 0x07, 0x10, 0x00, 0x14, //ERO object |
bharat saraswal | b4e5cbe | 2015-09-02 19:33:20 +0530 | [diff] [blame] | 141 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, |
| 142 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 143 | 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, //LSPA object |
| 144 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
| 145 | |
| 146 | byte[] testReportMsg = {0}; |
| 147 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 148 | buffer.writeBytes(reportMsg); |
| 149 | |
| 150 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 151 | PcepMessage message = null; |
| 152 | |
| 153 | message = reader.readFrom(buffer); |
Priyanka bhaskar | 3e1a697 | 2015-08-27 15:31:54 +0530 | [diff] [blame] | 154 | assertThat(message, instanceOf(PcepReportMsg.class)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 155 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 156 | message.writeTo(buf); |
| 157 | |
Priyanka bhaskar | 3e1a697 | 2015-08-27 15:31:54 +0530 | [diff] [blame] | 158 | int readLen = buf.writerIndex(); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 159 | testReportMsg = new byte[readLen]; |
| 160 | buf.readBytes(testReportMsg, 0, readLen); |
| 161 | |
Priyanka bhaskar | 3e1a697 | 2015-08-27 15:31:54 +0530 | [diff] [blame] | 162 | assertThat(testReportMsg, is(reportMsg)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | /** |
| 166 | * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object,BandWidth Object, |
| 167 | * Metric-list SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object,BandWidth Object,Metric-list, |
| 168 | * RRO Object |
| 169 | * in PcRpt message. |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 170 | */ |
| 171 | @Test |
| 172 | public void reportMessageTest42() throws PcepParseException { |
| 173 | |
| 174 | byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0xE8, |
| 175 | 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object |
bharat saraswal | b4e5cbe | 2015-09-02 19:33:20 +0530 | [diff] [blame] | 176 | 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 177 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv |
| 178 | 0x07, 0x10, 0x00, 0x14, //ERO object |
bharat saraswal | b4e5cbe | 2015-09-02 19:33:20 +0530 | [diff] [blame] | 179 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, |
| 180 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 181 | 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object |
| 182 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 183 | 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object |
| 184 | 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object |
| 185 | 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object |
bharat saraswal | b4e5cbe | 2015-09-02 19:33:20 +0530 | [diff] [blame] | 186 | 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 187 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv |
| 188 | 0x07, 0x10, 0x00, 0x14, //ERO object |
bharat saraswal | b4e5cbe | 2015-09-02 19:33:20 +0530 | [diff] [blame] | 189 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, |
| 190 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 191 | 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object |
| 192 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 193 | 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object |
| 194 | 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object |
| 195 | 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO object |
| 196 | 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, |
| 197 | 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, |
| 198 | 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, |
| 199 | 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, |
| 200 | 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; |
| 201 | |
| 202 | byte[] testReportMsg = {0}; |
| 203 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 204 | buffer.writeBytes(reportMsg); |
| 205 | |
| 206 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 207 | PcepMessage message = null; |
| 208 | |
| 209 | message = reader.readFrom(buffer); |
| 210 | |
Priyanka bhaskar | 3e1a697 | 2015-08-27 15:31:54 +0530 | [diff] [blame] | 211 | assertThat(message, instanceOf(PcepReportMsg.class)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 212 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 213 | message.writeTo(buf); |
| 214 | |
Priyanka bhaskar | 3e1a697 | 2015-08-27 15:31:54 +0530 | [diff] [blame] | 215 | int readLen = buf.writerIndex(); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 216 | testReportMsg = new byte[readLen]; |
| 217 | buf.readBytes(testReportMsg, 0, readLen); |
| 218 | |
Priyanka bhaskar | 3e1a697 | 2015-08-27 15:31:54 +0530 | [diff] [blame] | 219 | assertThat(testReportMsg, is(reportMsg)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 220 | } |
| 221 | } |