Priyanka B | 92803ad | 2015-10-31 10:55:40 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 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 | */ |
Ray Milkey | 753ad63 | 2015-11-06 08:46:33 -0800 | [diff] [blame] | 16 | package org.onosproject.bgpio.types; |
Priyanka B | 92803ad | 2015-10-31 10:55:40 +0530 | [diff] [blame] | 17 | |
Priyanka B | 01aefd3 | 2015-11-21 21:15:44 +0530 | [diff] [blame^] | 18 | import java.util.ArrayList; |
| 19 | import java.util.List; |
| 20 | |
| 21 | import org.jboss.netty.buffer.ChannelBuffer; |
| 22 | import org.jboss.netty.buffer.ChannelBuffers; |
Priyanka B | 92803ad | 2015-10-31 10:55:40 +0530 | [diff] [blame] | 23 | import org.junit.Test; |
Priyanka B | 92803ad | 2015-10-31 10:55:40 +0530 | [diff] [blame] | 24 | |
| 25 | import com.google.common.testing.EqualsTester; |
| 26 | |
| 27 | /** |
| 28 | * Test for IsIsPseudonode Tlv. |
| 29 | */ |
| 30 | public class IsIsPseudonodeTest { |
| 31 | private final byte[] value1 = new byte[] {0x01, 0x02, 0x01, 0x02, 0x01, 0x02}; |
Priyanka B | 01aefd3 | 2015-11-21 21:15:44 +0530 | [diff] [blame^] | 32 | byte value; |
| 33 | List<Byte> isoNodeID1 = new ArrayList<Byte>(); |
| 34 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
Priyanka B | 92803ad | 2015-10-31 10:55:40 +0530 | [diff] [blame] | 35 | private final byte[] value2 = new byte[] {0x01, 0x02, 0x01, 0x02, 0x01, 0x03}; |
Priyanka B | 01aefd3 | 2015-11-21 21:15:44 +0530 | [diff] [blame^] | 36 | List<Byte> isoNodeID2 = new ArrayList<Byte>(); |
| 37 | ChannelBuffer buffer1 = ChannelBuffers.dynamicBuffer(); |
| 38 | private final IsIsPseudonode tlv1 = IsIsPseudonode.of(isoNodeID1, (byte) 1); |
| 39 | private final IsIsPseudonode sameAsTlv1 = IsIsPseudonode.of(isoNodeID1, (byte) 1); |
| 40 | private final IsIsPseudonode tlv2 = IsIsPseudonode.of(isoNodeID2, (byte) 1); |
Priyanka B | 92803ad | 2015-10-31 10:55:40 +0530 | [diff] [blame] | 41 | |
| 42 | @Test |
| 43 | public void testEquality() { |
Priyanka B | 01aefd3 | 2015-11-21 21:15:44 +0530 | [diff] [blame^] | 44 | buffer.writeBytes(value1); |
| 45 | for (int i = 0; i < 6; i++) { |
| 46 | value = buffer.readByte(); |
| 47 | isoNodeID1.add(value); |
| 48 | } |
| 49 | buffer1.writeBytes(value2); |
| 50 | for (int i = 0; i < 6; i++) { |
| 51 | value = buffer1.readByte(); |
| 52 | isoNodeID1.add(value); |
| 53 | } |
Priyanka B | 92803ad | 2015-10-31 10:55:40 +0530 | [diff] [blame] | 54 | new EqualsTester() |
| 55 | .addEqualityGroup(tlv1, sameAsTlv1) |
| 56 | .addEqualityGroup(tlv2) |
| 57 | .testEquals(); |
| 58 | } |
Ray Milkey | 753ad63 | 2015-11-06 08:46:33 -0800 | [diff] [blame] | 59 | } |