blob: 070ae732faf7c498eacbd881ed4df993cb467e05 [file] [log] [blame]
Jian Lie9af3b42016-08-08 15:50:01 +09001/*
2 * Copyright 2016-present 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 */
16package org.onosproject.lisp.msg.types;
17
18import com.google.common.collect.Lists;
19import com.google.common.testing.EqualsTester;
20import org.junit.Before;
21import org.junit.Test;
22import org.onlab.packet.IpAddress;
23
24import java.util.List;
25
26import static org.hamcrest.MatcherAssert.assertThat;
27import static org.hamcrest.Matchers.is;
28
29/**
30 * Unit tests for LispListLcafAddress class.
31 */
32public class LispListLcafAddressTest {
33
34 private LispListLcafAddress address1;
35 private LispListLcafAddress sameAsAddress1;
36 private LispListLcafAddress address2;
37
38 @Before
39 public void setup() {
40
41 LispAfiAddress ipv4Address1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1"));
42 LispAfiAddress ipv6Address1 = new LispIpv6Address(IpAddress.valueOf("1111:2222:3333:4444:5555:6666:7777:8885"));
43
44 List<LispAfiAddress> afiAddresses1 = Lists.newArrayList();
45 afiAddresses1.add(ipv4Address1);
46 afiAddresses1.add(ipv6Address1);
47
48 address1 = new LispListLcafAddress(afiAddresses1);
49
50 sameAsAddress1 = new LispListLcafAddress(afiAddresses1);
51
52 LispAfiAddress ipv4Address2 = new LispIpv4Address(IpAddress.valueOf("192.168.2.1"));
53 LispAfiAddress ipv6Address2 = new LispIpv6Address(IpAddress.valueOf("1111:2222:3333:4444:5555:6666:7777:8886"));
54
55 List<LispAfiAddress> afiAddresses2 = Lists.newArrayList();
56 afiAddresses2.add(ipv4Address2);
57 afiAddresses2.add(ipv6Address2);
58
59 address2 = new LispListLcafAddress(afiAddresses2);
60 }
61
62 @Test
63 public void testEquality() {
64 new EqualsTester()
65 .addEqualityGroup(address1, sameAsAddress1)
66 .addEqualityGroup(address2).testEquals();
67 }
68
69 @Test
70 public void testConstruction() {
71 LispListLcafAddress listLcafAddress = address1;
72
73 LispAfiAddress ipv4Address1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1"));
74 LispAfiAddress ipv6Address1 = new LispIpv6Address(IpAddress.valueOf("1111:2222:3333:4444:5555:6666:7777:8885"));
75
76 List<LispAfiAddress> afiAddresses1 = Lists.newArrayList();
77 afiAddresses1.add(ipv4Address1);
78 afiAddresses1.add(ipv6Address1);
79
80 assertThat(listLcafAddress.getAddresses(), is(afiAddresses1));
81 }
82}