blob: 00e85dcf2f4ce5db7d3d9eed7bd491764d5db0f6 [file] [log] [blame]
Priyanka B92803ad2015-10-31 10:55:40 +05301/*
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 Milkey753ad632015-11-06 08:46:33 -080016package org.onosproject.bgpio.types;
Priyanka B92803ad2015-10-31 10:55:40 +053017
Priyanka B01aefd32015-11-21 21:15:44 +053018import java.util.ArrayList;
19import java.util.List;
20
21import org.jboss.netty.buffer.ChannelBuffer;
22import org.jboss.netty.buffer.ChannelBuffers;
Priyanka B92803ad2015-10-31 10:55:40 +053023import org.junit.Test;
Priyanka B92803ad2015-10-31 10:55:40 +053024
25import com.google.common.testing.EqualsTester;
26
27/**
28 * Test for IsIsPseudonode Tlv.
29 */
30public class IsIsPseudonodeTest {
31 private final byte[] value1 = new byte[] {0x01, 0x02, 0x01, 0x02, 0x01, 0x02};
Priyanka B01aefd32015-11-21 21:15:44 +053032 byte value;
33 List<Byte> isoNodeID1 = new ArrayList<Byte>();
34 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
Priyanka B92803ad2015-10-31 10:55:40 +053035 private final byte[] value2 = new byte[] {0x01, 0x02, 0x01, 0x02, 0x01, 0x03};
Priyanka B01aefd32015-11-21 21:15:44 +053036 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 B92803ad2015-10-31 10:55:40 +053041
42 @Test
43 public void testEquality() {
Priyanka B01aefd32015-11-21 21:15:44 +053044 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 B92803ad2015-10-31 10:55:40 +053054 new EqualsTester()
55 .addEqualityGroup(tlv1, sameAsTlv1)
56 .addEqualityGroup(tlv2)
57 .testEquals();
58 }
Ray Milkey753ad632015-11-06 08:46:33 -080059}