blob: 99077d1df543eea67fada7d1c96aae66ef2be14f [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.testing.EqualsTester;
19import org.junit.Before;
20import org.junit.Test;
21
22import static org.hamcrest.MatcherAssert.assertThat;
23import static org.hamcrest.Matchers.is;
24
25/**
26 * Unit tests for LispLcafAddress class.
27 */
28public class LispLcafAddressTest {
29
30 private LispLcafAddress address1;
31 private LispLcafAddress sameAsAddress1;
32 private LispLcafAddress address2;
33
34 @Before
35 public void setup() {
36
37 address1 = new LispLcafAddress(LispCanonicalAddressFormatEnum.NAT,
38 (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01);
39 sameAsAddress1 = new LispLcafAddress(LispCanonicalAddressFormatEnum.NAT,
40 (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01);
41 address2 = new LispLcafAddress(LispCanonicalAddressFormatEnum.NAT,
42 (byte) 0x02, (byte) 0x02, (byte) 0x02, (byte) 0x02);
43 }
44
45 @Test
46 public void testEquality() {
47 new EqualsTester()
48 .addEqualityGroup(address1, sameAsAddress1)
49 .addEqualityGroup(address2).testEquals();
50 }
51
52 @Test
53 public void testConstruction() {
54 LispLcafAddress lcafAddress = address1;
55
56 assertThat(lcafAddress.getType(), is(LispCanonicalAddressFormatEnum.NAT));
57 assertThat(lcafAddress.getReserved1(), is((byte) 0x01));
58 assertThat(lcafAddress.getReserved2(), is((byte) 0x01));
59 assertThat(lcafAddress.getFlag(), is((byte) 0x01));
60 assertThat(lcafAddress.getLength(), is((byte) 0x01));
61 }
62}