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